package com.parkinglot.controller;

import com.parkinglot.core.Result;
import com.parkinglot.parmeter.*;
import com.parkinglot.pojo.Order;
import com.parkinglot.service.GarageService;
import com.parkinglot.service.MonthbilRecordService;
import com.parkinglot.service.OrderService;
import com.parkinglot.util.HttpUrlutils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("garagectr")
@Api(tags = "车库接口")
@Slf4j
public class GarageController {

    @Resource
    private GarageService garageService;
    @Resource
    private OrderService orderService;
    @Resource
    private MonthbilRecordService monthbilRecordService;
    @Resource
    private HttpUrlutils httpUrlutils;

    @ApiOperation(value = "新增车库")
    @PostMapping("/addgarage")
    public Result getalluser(GarageaddParm garageaddParm){
        return Result.success(garageService.addGarage(garageaddParm));
    }

    @ApiOperation(value = "删除车库")
    @PostMapping("/delgarage")
    public Result delgarage(GaragedelParm garagedelParm){
        return Result.success(garageService.delGarage(garagedelParm));
    }

    @ApiOperation(value = "修改或删除车库")
    @PostMapping("/updgarage")
    public Result updgarage(@RequestBody GarageupdParm garageupdParm){
        return Result.success(garageService.updgarage(garageupdParm));
    }

    @ApiOperation(value = "查询车库")
    @GetMapping("/querygarage")
    public Result querygarage(GaragequeryParm garagequeryParm){
        return Result.success(garageService.querygarage(garagequeryParm));
    }

    @ApiOperation(value = "车库订单列表（根据选择的日期展示当天车库的车辆停放记录列表）")
    @GetMapping("/querygarageorderrecord")
    public Result querygarageorderrecord(OrderqueryParm orderqueryParm){
        return Result.success(garageService.querygarageorderrecord(orderqueryParm));
    }

 /*   @ApiOperation(value = "车库车辆统计（统计车辆时间段统计，可看出停车高峰期等）")
    @GetMapping("/countgaragecar")
    public Result countgaragecar(GarageCarCountParm garageCarCountParm){
        return Result.success(garageService.countgaragecar(garageCarCountParm));
    }*/

  /*  @ApiOperation(value = "车库收入统计（主要统计车库每日两小时一次收入汇总金额）")
    @GetMapping("/countgaraagemoney")
    public Result countgaraagemoney(OrderqueryParm orderqueryParm){
        return Result.success(orderService.countgaraagemoney(orderqueryParm));
    }*/

    @ApiOperation(value = "某一个车库上周每天收入统计（主要统计车某库上一周每天收入汇总金额）")
    @GetMapping("/garageweekmoney")
    public Result garageweekmoney(OrderqueryParm orderqueryParm){
        return Result.success(orderService.garageweekmoney(orderqueryParm));
    }

    @ApiOperation(value = "全部车库上周每天收入统计（主要统计全部车库上一周每天收入汇总金额）")
    @GetMapping("/allgarageweekmoney")
    public Result allgarageweekmoney( ){
        return Result.success(orderService.allgarageweekmoney());
    }

    @ApiOperation(value = "某一个车库上个月收入统计（主要统计车某库上个月收入汇总金额）")
    @GetMapping("/garagesymoney")
    public Result garagemonthmoney(OrderqueryParm orderqueryParm){
        return Result.success(orderService.garagemonthmoney(orderqueryParm));
    }

 /*   @ApiOperation(value = "某个车库或者全部车库总收益")
    @GetMapping("/garagemoney")
    public Result garagemoney(OrderqueryParm orderqueryParm){
        return Result.success(orderService.garagemoney(orderqueryParm));
    }*/

 /*   @ApiOperation(value = "某个车库或者全部车库车辆总数")
    @GetMapping("/countcar")
    public Result countcar(OrderqueryParm orderqueryParm){
        return Result.success(orderService.countcar(orderqueryParm));
    }*/

/*    @ApiOperation(value = "全部统计各个车库昨日停车总数")
    @GetMapping("/countgaragestopcar")
    public Result countgaragecar(){
        return Result.success(orderService.countgaragecars());
    }*/

   /* @ApiOperation(value = "全部车库上月每天收益统计")
    @GetMapping("/garagemonth")
    public Result garagemonth(OrderqueryParm orderqueryParm){
        return Result.success(orderService.garagemonth(orderqueryParm));
    }*/

/*    @ApiOperation(value = "查询所有停车场")
    @GetMapping("/allgarage")
    public Result allgarage(){
        return Result.success(garageService.allgarage());
    }*/

 /*   @ApiOperation(value = "小程序生成订单")
    @PostMapping("scorder")
    public Result order( @RequestBody Order order){
        return Result.success(orderService.insert(order));
    }*/
 @ApiOperation(value = "小程序查看订单详情")
 @PostMapping("getordetdetil")
 public Result order( @RequestBody Order order){
     return Result.success(orderService.getordetdetil(order));
 }

    @ApiOperation(value = "接受数据生成订单")
    @PostMapping("newScorder")
    public Result newScorder(Order order){
        return Result.success(orderService.inserts(order));
    }
    @ApiOperation(value = "用户会员过期处理")
    @GetMapping("getusermonthvip")
    public Result monthvip(MonthVipParm monthVipParm){
        return Result.success(monthbilRecordService.monthcipguoqi(monthVipParm));
    }

    @ApiOperation(value = "用户点击确定出场")
    @PostMapping("garageout")
    public Result garageout(@RequestBody GarageUser garageUser){
                  /*  String tgurl = "http://192.168.3.205:8080/inPark/unlicensedInPark?carNumber="
                        + garageUser.getCarnumber()
                        + "&parkId="
                        + garageUser.getGarageCode();
                Map<String, Object> map = httpUrlutils.getresult(tgurl);*/

        return Result.success(garageService.outgarage(garageUser));
    }

}
